home *** CD-ROM | disk | FTP | other *** search
- Path: bcarh8ab.bnr.ca!jcobban
- From: jcobban@bnr.ca (Jim Cobban)
- Newsgroups: comp.lang.c++
- Subject: Re: Deriving class from IOSTREAMs
- Date: 16 Apr 1996 13:39:00 GMT
- Organization: Bell-Northern Research Canada
- Message-ID: <4l07tk$djq@bcarh8ab.bnr.ca>
- References: <4ku9qa$7mt@bcarh8ab.bnr.ca> <3172F862.7053@braunschweig.netsurf.de>
- Reply-To: jcobban@nortel.ca (Jim Cobban)
- NNTP-Posting-Host: bcarsf1f.bnr.ca
-
-
- In article <3172F862.7053@braunschweig.netsurf.de>,
- Dieter Lⁿcking <luecking@braunschweig.netsurf.de> wrote:
- >Jim Cobban wrote:
- >>
- >> I am trying to define a class which has the following characteristics:
- >>
- >> 1) It supports the insertion (<<) operator of the ostream class.
- >> 2) Output is organized into units of work. No part of a unit of work
- >> can be written to the output device until the unit of work is complete.
- >> Then all of the text in the unit of work must be placed on the same line
- >> of output. In other words if there is enough room on the current line
- >> to hold all of the text then it will be printed on the current line,
- >> otherwise a new line is started and the text is written on the new line.
- >> 3) When a new line is started, including the very first line in the output,
- >> an application specified prefix is written before the first unit of
- >> work.
- >>
- >> The first requirement dictates that my class be derived directly or
- >> indirectly from ostream.
- >
- >[1] No - this is wrong - you may use "ostream& operator << (ostream&, const aclass&);"
- >
- You have misunderstood. I do not want to be able to insert an instance of my
- class into an ostream. I want my class to support all of the insertions
- which are part of the ostream class. So my class has to be on the left hand
- side of the insertion operator.
-
- Or possibly I have misunderstood your point.
-
- >> The second requirement seems to me to dictate that
- >> my class be derived, in particular, from ostrstream, which provides a buffer
- >> in which output can be held until a unit of work is complete. I would like
- >> the end of a unit of work to be signalled by a manipulator, but I have had a
- >> great deal of difficulty in getting that to work.
- >> [...]
- >
- >[2,3] It is possible to use "ostream& operator << (ostream&, const aclass&);", too.
- >
- >Bye Dieter.
- >
- >
-
-
- --
- Jim Cobban | jcobban@nortel.ca | Phone: (613) 763-8013
- Nortel (MCS) | | FAX: (613) 763-5199
- | |
- | The opinions expressed are those of the author and do not necessarily |
- | represent the opinions of Nortel. |
-